﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Spymaster.Screens;

namespace Spymaster
{
    public class GameController 
        : DrawableGameComponent
    {
        private Game game;
        private GraphicsDeviceManager graphics;

        private List<AbstractScreen> screens;
        public List<AbstractScreen> Screens
        {
            get { return screens; }
        }

        public GameController(Game game, GraphicsDeviceManager g) 
            : base(game)
        {            
            this.screens = new List<AbstractScreen>();
            this.game = game;
            this.graphics = g;
        }

        public override void Initialize()
        {
            GameScreen gameScreen = new GameScreen(game, graphics);
            gameScreen.Initialize();
            gameScreen.LoadContent(Game.Content);
            screens.Add(gameScreen);

            base.Initialize();
        }

        protected override void LoadContent()
        {
            base.LoadContent();
        }

        protected override void UnloadContent()
        {
            base.UnloadContent();
        }

        public override void Update(GameTime gameTime)
        {
            foreach (AbstractScreen screen in screens)
            {
                screen.Update(gameTime);
            }

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            Game.GraphicsDevice.Clear(Color.CornflowerBlue);

            foreach (AbstractScreen screen in screens)
            {
                screen.Draw(gameTime);
            }

            base.Draw(gameTime);
        }
    }
}
